/*
 * stack.c
 *
 *  Created on: 2009-5-14
 *      Author: hwg
 */
#include"../header/common.h"
void cinitian(cstack *s)
{
	s->top = 0;
}
int cinitia(cstack *s ,char *buff)
{
	if(sizeof(s->stack) > strlen(buff))
	{
		int i = strlen(buff);
		i = i - 1;
		while(i>=0)
		{
			cpush(s,buff[i]);

			i = i -1;
		}
		return ok;
	}
	else
	{
		return error;
	}
}
int cpush(cstack * s , char n)
{
	if(sizeof(s->stack) >= s->top)
	{
		s->stack[s->top] = n;
		s->top = s->top + 1;
		return 1;
	}
	else
		return  -1;

}
char cpop(cstack *s)
{
	if(s->top >0)
	{
		s->top = s->top - 1;
		return s->stack[s->top];
	}
	else
	{
		return '\'';
	}
}

char cgettop(cstack *s)
{
	if(s->top >0)
		{
			return s->stack[s->top - 1];
		}
		else
			return '\'';
}
